package com.example.demo.service;

import com.example.demo.mapper.CommentMapper;
import com.example.demo.pojo.Comment;
import com.example.demo.pojo.Goodsaddguanli;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author yanglup
 * @create 2020-12-13 20:31
 */
@Service
public class CommentServerImpl implements CommentServer{
    @Autowired
    CommentMapper commentMapper;

    /**添加评论*/
    @Override
    public void commonentadd(String openid, String comment_time, String comment_text, String nickName, Integer likenumber,String avatarUrl,Integer goods_id) {
        commentMapper.commonentadd(openid,comment_time,comment_text,nickName,likenumber,avatarUrl,goods_id);
    }

    /**查询评论列表*/
    @Override
    public List<Comment> commonentlist(Integer goods_id) {
        return commentMapper.commonentlist(goods_id);
    }


    /**查询评论列表数量*/
    @Override
    public Integer commonentnumbers(Integer goods_id) {
        return commentMapper.commonentnumbers(goods_id);
    }


    /**查询是否有存在评论id*/
    @Override
    public Comment commentidcheck(Integer comment_id) {
        return commentMapper.commentidcheck(comment_id);
    }

    /**如果没找like过就添加like*/
    @Override
    public void commonentlikenumber(Integer comment_id) {
        commentMapper.commonentlikenumber(comment_id);
    }


    /*********************************************评论后台管理平台*******************************************************************/
    /**后台查询评论列表*/
    @Override
    public PageInfo<Comment> Commentlist(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Comment> mycommentlist= commentMapper.Commentlist();
        PageInfo<Comment> myPageInfo=new PageInfo<Comment>(mycommentlist,pageSize);
        return myPageInfo;
    }
    /**查询评论列表数量*/
    @Override
    public Integer Commentlistnumber() {
        return commentMapper.Commentlistnumber();
    }

    /**删除评论*/
    @Override
    public void Commentdelete(Integer comment_id) {
        commentMapper.Commentdelete(comment_id);
    }

    /**搜索*/
    @Override
    public List<Comment> Commentlistquery(String comment_text) {
        return commentMapper.Commentlistquery(comment_text);
    }

    /**搜索数量*/
    @Override
    public Integer Commentlistquerynumber(String comment_text) {
        return commentMapper.Commentlistquerynumber(comment_text);
    }

}
